package _3_data_struct;

import org.junit.Test;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;


/**
 * @see HashMap
 */
public class AboutHashMap {

    /**
     * 数据结构: {@link HashMap.Node}  {@link HashMap.TreeNode}  {@link }
     *//*   HashMap 的数据结构是 HashMap.Node[] , 也就是一个数组, 数组的元素是链表, 链表过长转为红黑树 (HashMap.TreeNode)
     *
     */
    public void dataStructure() {
        // 测试 链表对象转为红黑树

    }

    @Test
    public void test() {
        HashMap<Object, Object> map = new HashMap<>();
        map.putAll(null);
        System.out.println(map);
    }


    @Test
    public void testPut() {
        HashMap<Object, Object> map = new HashMap<>();
        map.put("1", "1");
        map.put("2", null);
        Object old = map.putIfAbsent("2", "2");
        Object old2 = map.putIfAbsent("3", "3");
        System.out.println(map.get("2"));
    }

    public static void main(String[] args) {
        Map a = new ConcurrentHashMap();
        a.put("a", "a");
        Object b = a.get("test");
        System.out.println(b);
    }
}
